﻿using System;
using Microsoft.Practices.Unity;
using ReactiveGraph.Core;
using ReactiveGraph.Core.Configuration.Containers;


namespace ReactiveGraph.Tests.Containers
{
    public class UnityTestContainer : IReactiveNodeContainer
    {
        readonly UnityContainer _container = new UnityContainer();

        public UnityTestContainer()
        {
            _container.AddExtension(new UnityCoreExtension());
        }


        public T GetNode<T>() where T : class, IReactiveNode
        {
            return _container.Resolve<T>();
        }

        public T GetNode<T>(string name) where T : class, IReactiveNode
        {
            var func = _container.Resolve<Func<string, Type, IReactiveNode>>();
            return (T)func(name, typeof(T));
        }
    }
}
